﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBModel.DAL
{
   public class ApplicantDB
    {  
       public static List<Applicant> GetAllApplicants()
        {
            return DB.Context.Users.OfType<Applicant>().Where(a => !a.IsDeleted).ToList();
        }

        public static Applicant GetApplicantById(int id)
        {
            var applicant =
                         (from a in DB.Context.Users.OfType<Applicant>()
                          where a.UserId == id && !a.IsDeleted
                          select a).SingleOrDefault();
            return applicant;
        }

        public static bool DeleteApplicantById(int id)
        {
            Applicant user = ApplicantDB.GetApplicantById(id);
            if (user != null)
            {
                user.IsDeleted = true;
                int affectedRows = DB.Context.SaveChanges();
                return (affectedRows > 0);
            }
            return false;
        }
    }
}

  
